<template>
  <CommonCard title="累计订单额" :value="reportData.orderToday">
    <template #default>
      <v-chart :option="option"></v-chart>
    </template>
    <template #footer>
      <span>昨日销售额</span>
      <span class="css-1">{{ reportData.orderLastDay }}</span>
    </template>
  </CommonCard>
</template>

<script setup>
import { ref, watch } from 'vue'
import CommonCard from './CommonCard.vue'

const props = defineProps({
  reportData: {
    type: Object,
    required: true,
  },
})

const option = ref({})

const renderChart = (data) => {
  option.value = {
    title: {
      name: '累计订单额',
      show: false,
    },
    xAxis: {
      type: 'category',
      show: false,
      boundaryGap: false,
    },
    yAxis: {
      type: 'value',
      show: false,
    },
    grid: {
      top: 0,
      left: 0,
      right: 0,
      bottom: 0,
    },
    series: {
      name: '累计订单额',
      type: 'line',
      data: data,
      smooth: true,
      areaStyle: {
        color: 'purple',
      },
      lineStyle: {
        opacity: 0,
      },
      itemStyle: {
        opacity: 0,
      },
    },
  }
}

watch(props, () => {
  renderChart(props.reportData.orderTrend)
})
</script>

<style scoped></style>
